---
layout: "default"
title: "SequenceType"
description: "Swift documentation for 'SequenceType': A type that can be iterated with a for...in loop."
keywords: "SequenceType,protocol,swift,documentation,generate,Generator"
root: "/v1.2"
---

<div class="intro-declaration"><code class="language-swift">protocol SequenceType</code></div>

<div class="discussion comment">
    <p>A type that can be iterated with a <code>for</code>...<code>in</code> loop.</p>

<p><code>SequenceType</code> makes no requirement on conforming types regarding
whether they will be destructively &quot;consumed&quot; by iteration.  To
ensure non-destructive iteration, constrain your <em>sequence</em> to
<code>CollectionType</code>.</p>
</div>

<table class="standard">
<tr>
<th id="inheritance">Inheritance</th>
<td>
<code class="inherits">_SequenceType, _Sequence_Type</code>
<span class="viz"><a href="hierarchy/">View Protocol Hierarchy &rarr;</a></span>
</td>
</tr>

<tr>
<th id="aliases">Associated Types</th>
<td>
<span id="aliasesmark"></span>
<div class="declaration">
<code class="language-swift">Generator : GeneratorType</code>
<div class="comment">
    <p>A type that provides the <em>sequence</em>&#39;s iteration interface and
encapsulates its iteration state.</p>
</div>
</div>
</td>
</tr>


<tr>
<th>Import</th>
<td><code class="language-swift">import Swift</code></td>
</tr>

</table>







<h3>Instance Methods</h3>
<div class="declaration" id="func-generate">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-generate">func generate()</a>
     <span class="required">Required</span>    
<div class="comment collapse" id="comment-func-generate"><div class="p">
    <p>Return a <em>generator</em> over the elements of this <em>sequence</em>.</p>

<p>Complexity: O(1)</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func generate() -&gt; Generator</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/SequenceType/"><code>SequenceType</code></a>,    <a href="../../protocol/_Sequence_Type/"><code>_Sequence_Type</code></a>    
</div></div>
</div>


